layui.use(['form', 'layer', 'table', 'laydate', 'func', 'ax'], function () {
    var layer = layui.layer;
    var table = layui.table;
    var form = layui.form;
    var laydate = layui.laydate;
    var func = layui.func;
    var $ax = layui.ax;

    /**
     * 初始化表单，要加上，不然刷新部分组件可能会不加载
     */
    form.render();

    /**
     * 初始化表格
     */
    var BrankBannerOne = {
        tableId: "BrankBannerOneTable" //表格id
    };

    /**
     * 初始化表格的列
     */
    BrankBannerOne.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'oneImage', align: "center", sort: true, title: '图一',
                templet: function(object){
                    return '<img src="/hyRedWineFile/images/' + object.oneImage + '" style="width: 100px;">';
                }
            },
            {field: 'twoImage', align: "center", sort: true, title: '图二',
                templet: function(object){
                    return '<img src="/hyRedWineFile/images/' + object.twoImage + '" style="width: 100px;">';
                }
            },
            {field: 'title', align: "center", sort: true, title: '标题'},
            {field: 'content', align: "center", sort: true, title: '内容'},
            {field: 'updateDate', align: "center", sort: true, title: '更新时间'},
            {field: 'userName', align: "center", sort: true, title: '更新者'},
            {align: 'center', toolbar: '#tableBar', title: "操作", minWidth: 80}
        ]];
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + BrankBannerOne.tableId,
        url: Feng.ctxPath + '/rw/brankBannerOne/list',
        page: true,
        limits: [10, 15, 20, 25, 50, 100],
        limit: 15,
        height: "full-98",
        cellMinWidth: 100,
        cols: BrankBannerOne.initColumn()
    });

    /**
     * 弹出编辑对话框
     */
    BrankBannerOne.Twodit = function (data) {
        func.open({
            title: "编辑",
            maxmin: true,
            height: 700,
            content: Feng.ctxPath + '/rw/brankBannerOne/addOrEdit?brankBannerOneId=' + data.id,
            tableId: BrankBannerOne.tableId
        });
    };

    // 工具条点击事件
    table.on('tool(' + BrankBannerOne.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;

        if (layEvent === 'edit') {
            BrankBannerOne.Twodit(data);
        }
    });

});

$(function () {
    var panehHidden = false;
    if ($(this).width() < 769) {
        panehHidden = true;
    }
    $('#myContiner').layout({initClosed: panehHidden, west__size: 260});
});